home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Memory / Stacks / FiniteStackBase.h < prev   
Encoding:
Text File  |  1997-06-28  |  744 b   |  37 lines  |  [TEXT/CWIE]

  1. // FiniteStackBase.h
  2.  
  3. #ifndef FiniteStackBase_h
  4. #define FiniteStackBase_h
  5.  
  6. #ifndef Integers_h
  7. #include "Integers.h"
  8. #endif
  9.  
  10. class FiniteStackBase
  11.   {
  12.     private:
  13.         uint8 *const start;
  14.         uint8 *const end;
  15.         const uint32 elementSize;
  16.         
  17.         uint8 *allocateNext;
  18.         
  19.         // not implemented:
  20.             FiniteStackBase( const FiniteStackBase& );
  21.             void operator=( const FiniteStackBase& );
  22.         
  23.     public:
  24.         FiniteStackBase( void *theSpace, uint32 length, uint32 elementSize );
  25.         
  26.         bool Full() const            { return allocateNext >= end; }
  27.         bool IsEmpty() const        { return allocateNext <= start; }
  28.  
  29.         void *Allocate( uint32 size );
  30.         void Release( void * );
  31.   };
  32.  
  33. inline void *operator new( uint32 size, FiniteStackBase& pool )
  34.     { return pool.Allocate( size ); }
  35.  
  36. #endif
  37.